package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.Role;
import com.zzyl.vo.RoleVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Role record);

    int insertSelective(Role record);

    Role selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    int batchInsert(@Param("list") List<Role> list);


    //分页条件查询
    Page<RoleVo> selectPage(String roleName);

    //查询角色名是否存在，返回数量
    Long selectByName(String roleName);

    //查询角色名是否存在【除自身外】，返回数量
    @Select("select count(1) from sys_role where role_name=#{roleName} and !id=#{id};")
    Long selectByNameWithoutSelf(Role role);

    //查询状态
    @Select("select data_state from sys_role where id=#{roleId}")
    String getStatus(Long roleId);

    //角色下拉框
    @Select("select * from sys_role")
    List<RoleVo> selectInitRoles();
}